import requests
import json
from get_field_name.save_to_db import *

def get_first_field_name(url):
    try:
        response = requests.get(url)
        if response.content:  # 返回成功
            return response.content
    except requests.ConnectionError as e:
        print('url出错', e.args)

if __name__ == '__main__':
    url = "https://academic.microsoft.com/api/analytics/topics/hierarchy?topicPath="
    first_filed_name = json.loads(get_first_field_name(url))['ct']
    # print(first_filed_name)
    save_data("first_name", first_filed_name)